<template>
	<div class="container">
		<h3 class="header-title clearfix">
			<span></span>
			<p>家政从业者管理</p>
		</h3>
		<!-- 导航栏 -->
		<comNavTabs :navList="navList" @switch="tabSwitch"></comNavTabs>
		<!-- 搜索条件：注册时间，用户名，电话等 -->
		<comSearch v-if="searchList.show" ref="search" :options="searchList"
			@searchList="evaluatedList"
		></comSearch>
		<!-- 数据展示的列表 -->
		<comTable :options="tableList"
			@openReport="openRepDialog" @openEval="openEvalDialog"
			@openFeedback="openFeedDialog" @openUnrep="openUnrepDialog"
			@viewChanges="openViewchangeDialog" @openAssess="openAssessDialog"
			@openRemark="openRemarkDialog" @openDefriend="openDefriendDialog"
		></comTable>
		<!-- 自评报告弹窗 -->	
		<praReport :options="reportList" ref="reportDialog"></praReport>	
		<!-- 预约人员-回馈操作弹窗 -->
		<praFeedback ref="feedback" :options="feedback" @subFeedback="submitFeedback"></praFeedback>
		<!-- 待测评人员-测评弹窗 -->
		<praEval :options="evalution" @subEval="submitEval" :intentionJob.sync="intentionJob" ref="eval"></praEval>
		<!-- 待测评人员-未报到弹窗 -->
		<praUnreported ref="unrep" :options="unrep" @subUnrep="submitEnrep"
			@subDefriend="submitDefriend"
		></praUnreported>
		<!-- 已测评人员-姓名修改信息弹窗 -->
		<praViewChanges :options="viewchanges" ref="viewchanges" @modInfo="modifyInfo"></praViewChanges>
		<!-- 再次测评人员/已测评人员-测评报告弹窗 -->
		<praAssess :options="assess" ref="assess"></praAssess>
		<!-- 已测评人员-服务评语弹窗 -->
		<empEmployerLogsDialog ref="remark" :options="remark" @subDefriend="submitDefriend"></empEmployerLogsDialog>
		<!-- 未测评人员-点击名字跳出简历模板 -->
		<!-- <praResume ref="resume"></praResume> -->
		
		<!-- 分页器 -->
		<div class="pageBox">
			<el-pagination
				@size-change="handleSizeChange"
				@current-change="pageChange"
				:current-page.sync="cur"
				:page-sizes="[10, 20, 30, 50, 100]"
				:page-size="pageSize"
				layout="total, sizes, prev, pager, next, jumper"
				:total="totalNum"
				background
			></el-pagination>
		</div>
	</div>
</template>
<script>
import jobsJson from "../../assets/jobs.json";
export default{
	components:{
		comNavTabs: () => import("../common/comNavTabs.vue"),
		comSearch: () => import("../common/comSearch.vue"),
		comTable: () => import("../common/comTable.vue"),
		praReport: () => import("../common/praReport.vue"),
		praFeedback: () => import("../common/praFeedback.vue"),
		praEval: () => import("../common/praEval.vue"),
		praUnreported: () => import("../common/praUnreported.vue"),
		praViewChanges: () => import("../common/praViewChanges.vue"),
		praAssess: () => import("../common/praAssess.vue"),
		empEmployerLogsDialog: () => import("../common/empEmployerLogsDialog.vue")
	},
	data(){
		return {
			userinfo:{},				//登录者账户信息
			/* 导航栏列表数据 */
			navList:{
				index:0,		//当前是在哪个tab栏
				data:[
					{title:'预约人员'},
					{title:'待测评人员'},
					{title:'再次测评人员'},
					{title:'已测评人员'},
					{title:'未测评人员'}
				]	
			},
			/* 搜索栏数据 */
			searchList:{
				show:false,				//是否显示搜索栏
				noTime:false,			//有没有时间
				noTelphone:false,		//有没有电话
				noUser:false,			//有没有实名用户名
				noSalary:false,			//有没有薪资待遇
				noEmployer:false,		//有没有雇主
				noCity:false,			//有没有所在地
				noPosition:false,		//有没有职位名称
				/* pageSize: 10,			//当前页数显示多少条数据
				pageNum:1				//当前是第几页	 */
			},
			/* 保留下来的搜索数据 */
			searchData:{},
			/* 表格数据 */
			tableList:{
				list:[],
				noOperation:true,	//是否有操作项
				operation:[			//操作项内容
					// 
				],
				data:[]
			},
			reportList:{
				userinfo:{},					//被查看的自评报告的用户信息
				username:'',
				telphone:'',
				job:'',
				skillListPre:[
					{name:'餐饮综合',per:17},
					{name:'家常菜',per:59},
					{name:'面食',per:100},
					{name:'餐饮综合',per:17},
					{name:'家常菜',per:59},
					{name:'面食',per:100},
					{name:'餐饮综合',per:17},
					{name:'家常菜',per:59},
					{name:'面食',per:100},
					{name:'餐饮综合',per:17},
					{name:'家常菜',per:59},
					{name:'面食',per:100},
					{name:'餐饮综合',per:17},
					{name:'家常菜',per:59},
					{name:'面食',per:100}
				],
				skillListNext:[
					{name:'餐饮综合',per:17},
					{name:'家常菜',per:59},
					{name:'面食',per:100},
					{name:'餐饮综合',per:17},
					{name:'家常菜',per:59},
					{name:'面食',per:100},
					{name:'餐饮综合',per:17},
					{name:'家常菜',per:59},
					{name:'面食',per:100},
					{name:'餐饮综合',per:17},
					{name:'家常菜',per:59},
					{name:'面食',per:100},
					{name:'餐饮综合',per:17},
					{name:'家常菜',per:59},
					{name:'面食',per:100}
				]
			},
			feedback:{
				title:"回馈",						//弹窗标题
				noNav:true,							//是否有选项
				eventName:'subFeedback',			//提交事件的名称
				userinfo:{}							//当前接收回馈消息人员的信息
			},
			intentionJob:'',			//待测评人员-测评弹窗-意向职位
			evalution:{					
				userinfo:{},
				radioList:[
					{label:'001',jobName:'保姆'},
					{label:'002',jobName:'月嫂'},
					{label:'003',jobName:'育婴师'},
					{label:'004',jobName:'养老护理'},
					{label:'005',jobName:'钟点工'},
					{label:'006',jobName:'护工'},
					{label:'007',jobName:'催乳师'},
					{label:'008',jobName:'产后康复师'},
					{label:'009',jobName:'母乳喂养指导师'},
					{label:'010',jobName:'其他家政职位'}
				],
				skillList:[
					/* {title:'形象',items:[
						{name:'一般',label:1,id:1},
						{name:'良好',label:2,id:2},
						{name:'优秀',label:3,id:3}
					],radio:1,id:1},
					{title:'气质',items:[
						{name:'一般',label:1,id:1},
						{name:'良好',label:2,id:2},
						{name:'优秀',label:3,id:3}
					],radio:1,id:2},
					{title:'厨艺',items:[
						{name:'一般',label:1,id:1},
						{name:'良好',label:2,id:2},
						{name:'优秀',label:3,id:3}
					],radio:1,id:3}, */
				],
			},
			unrep:{
				title:'未报到',
				linefeedPre:'确认该家政人员',
				linefeedNext:'是否未按时参加线下辅导站测评',
				subCon:'确认未报到',
				eventName:'subUnrep',
				modal:true,					
				userinfo:{}					//当前确认未报到人员的信息
			},
			viewchanges:{
				userinfo:{},		//被修改人员的信息
				username:'',
				tel:'',
				job:'',
				skillList:[						//技能测评
					/* {title:'形象',items:[
						{name:'一般',label:1,id:1},
						{name:'良好',label:2,id:2},
						{name:'优秀',label:3,id:3}
					],radio:1,id:1} */
				],
				rate:1,							//评分
				workPhotos:[],					//工作照片
				certificatePhotos:[],			//证书照片
				moneyList:[],					//薪酬范围
				value:1,						//绑定的是多少薪资
				dataList:{						//测评操作记录
					list:[
						{title:'门店名称',prop:'branchName',isClick:false},
						{title:'操作人员姓名',prop:'operationName',isClick:false},
						{title:'操作时间',prop:'createTime',isClick:false},
						{title:'操作状态',prop:'operationType',isClick:false}
					],
					noOperation:false,	//是否有操作项
					data:[]				
				},
			},
			assess:{
				username:'',
				tel:'',
				job:'',
				skillList:[						//技能测评
					/* {name:'形象',items:[
						{name:'一般',label:1,id:1},
						{name:'良好',label:2,id:2},
						{name:'优秀',label:3,id:3}
					],radio:2,id:1} */
				],
				rate:1,							//评分
				workPhotos:[],					//工作照片
				certificatePhotos:[],			//证书照片
				moneyList:[],					//薪资
				value:1,						//绑定的是多少薪资
			},
			remark:{
				title:'服务评语',
				list:[
					{title:'就职岗位',prop:'jobTitle',isClick:false},
					{title:'薪资范围',prop:'salaryRange',isClick:false},
					{title:'入职时间',prop:'entrydate',isClick:false},
					{title:'就职状态',prop:'jobStatus',isClick:false},
					{title:'评价得分',prop:'evaluate',isClick:false}
				],
				noOperation:false,	//是否有操作项
				data:[				//请求到的表格数据
					{
						jobTitle: '月嫂',									//就职岗位
						salaryRange: '6k-7k',								//薪资范围
						entrydate: '2020-03-09 11:30',						//入职时间
						jobStatus: '期后离职',								//就职状态
						evaluate: '一般',									//评价得分
						iconUrl:require('../../assets/img/select.png')		//评价得分图标
					}
				],
				cur:1,					//当前是第几页
				pageSize: 10,			//每页显示多少条数据
				totalNum:0			//数据条数
			},
			
			
			/* 分页功能数据 */
			cur:1,
			pageSize: 10,
			totalNum: 0,				//总共有多少条数据,根据这个数据去适配页数
		}
	},
	created(){
		this.assess.moneyList = jobsJson.moneyList;
		this.viewchanges.moneyList = jobsJson.moneyList;
		this.userinfo = JSON.parse(localStorage.getItem('userinfo'));
		console.log(this.userinfo);
		this.tabSwitch(this.navList.index);
	},
	watch:{
		'$store.getters.getCurBranchId'(){
			if(this.userinfo.grade === '11'){
				let _this = this;
				setTimeout(function(){
					_this.tabSwitch(_this.navList.index);
				},200)
			}
		}
		
	},
	methods:{
		//打开自评报告弹窗
		openRepDialog(data){	
			console.log(data);
			this.reportList.username = data.userName;
			this.reportList.telphone = data.phone;
			this.$houseAxios.post('/housekeeping/OfflineAppraisal/selectAppraisalRegidPC',{userId:data.userId}).then(res => {
				console.log(res);
				if(res.data.code === 1000){
					if(res.data.data != null){
						let result = res.data.data;
						jobsJson.jobNameList.forEach(item => {
							if(item.key == result.appraisalType){
								this.reportList.job = item.value;
								result.softs.forEach(item => {
									if(item.grade == '1'){
										item.per = 18;
									}else if(item.grade == '2'){
										item.per = 58;
									}else{
										item.per = 100;
									}
								})
								this.reportList.skillListPre = result.softs.slice(0,16);
								this.reportList.skillListNext = result.softs.slice(16);
							}
						})
						this.$refs.reportDialog.open();
					}else{
						this.$message({
							message: '该用户没有进行自评',
							type:'warning'
						})
					}
					
				}
			})
			// this.reportList.userinfo = data;
			
		},
		//tab栏切换
		tabSwitch(index){		
			this.navList.index = index;
			console.log(index);
			// console.log(this.navList.index);
			
			this.reset();
			if(index == 0){
				this.searchList.show = false;
				if(this.userinfo.grade === '10' || this.userinfo.grade === '13'){
					this.tableList.list = [
						{title:'姓名',prop:'userName',isClick:false},
						{title:'手机号',prop:'phone',isClick:false},
						{title:'预约时间',prop:'appointmentTime',isClick:false},
						{title:'预约网点',prop:'branchName',isClick:false},
						{title:'自评报告',prop:'report',isClick:true,eventName:'openReport'}
					];
					this.tableList.noOperation = false;
				}else{
					this.tableList.list = [
						{title:'姓名',prop:'userName',isClick:false},
						{title:'手机号',prop:'phone',isClick:false},
						{title:'预约时间',prop:'appointmentTime',isClick:false},
						{title:'自评报告',prop:'report',isClick:true,eventName:'openReport'}
					];
					this.tableList.noOperation = true;
					this.tableList.operation = [
						{name:'回馈',isBtn:false,title:'openFeedback'}
					];
				}
				// this.tableList.data.splice(0,this.tableList.data.length);
				this.tableList.data = [
					/* {
						userName: '谢镔',					//姓名
						phone: '16666666666',			//手机号
						appointmentTime: '2016-05-02 11:30',	//预约时间
						report: '查看',						//自评报告
					} */
				];
				this.resData(index);
			}else if(index == 1){
				this.searchList.show = false;
				this.tableList.list = [
					{title:'姓名',prop:'userName',isClick:false},
					{title:'手机号',prop:'phone',isClick:false},
					{title:'预约时间',prop:'appointmentTime',isClick:false},
					{title:'自评报告',prop:'report',isClick:true,eventName:'openReport'}
				];
				this.tableList.noOperation = true;
				this.tableList.operation = [
					{name:'测评',isBtn:false,title:'openEval'},
					{name:'未报道',isBtn:false,title:'openUnrep'}
				];
				this.tableList.data = [
					/* {
						userName: '谢镔',						//姓名
						phone: '16666666666',					//手机号
						appointmentTime: '2016-05-02 11:30',	//预约时间
						report: '查看',							//自评报告
					} */
				];
				this.resData(index);
			}else if(index == 2){
				this.searchList.show = false;
				this.tableList.list = [
					{title:'姓名',prop:'userName',isClick:false},
					{title:'手机号',prop:'phone',isClick:false},
					{title:'预约时间',prop:'appointmentTime',isClick:false},
					{title:'测评报告',prop:'report',isClick:true,eventName:'openAssess'}
				];
				this.tableList.noOperation = true;
				this.tableList.operation = [
					{name:'测评',isBtn:false,title:'openEval'},
					{name:'未报道',isBtn:false,title:'openUnrep'}
				];
				this.tableList.data = [
					/* {
						userName: '王五',						//姓名
						phone: '16666666666',					//手机号
						appointmentTime: '2016-05-02 11:30',	//预约时间
						report: '查看',							//自评报告
					} */
				];
				this.resData(index);
			}else if(index == 3){
				this.searchList.show = true;
				this.searchList.noTime = true;
				this.searchList.noUser = true;
				this.searchList.noCity = true;
				this.searchList.noTelphone = true;
				this.tableList.list = [
					{title:'姓名',prop:'username',isClick:true,eventName:'viewChanges'},
					{title:'手机号',prop:'phone',isClick:false},
					{title:'考评时间',prop:'checkTime',isClick:false},
					{title:'工作状态',prop:'jobstatus',isClick:false},
					{title:'测评报告',prop:'evalreport',isClick:true,eventName:'openAssess'},
					{title:'服务评语',prop:'remark',isClick:true,eventName:'openRemark'}
				];
				this.tableList.noOperation = true;
				this.tableList.operation = [
					{name:'拉黑',isBtn:true,title:'openDefriend'},
					{name:'提醒',isBtn:true,title:'openFeedback'}
				];
				this.tableList.data = [
					/* {
						username:'张三',						//姓名
						phone:'13333333333',				//手机号
						checkTime:'2020-04-25 11:30',		//考评时间
						jobstatus:'正在找工作',				//工作状态
						evalreport:'查看',					//测评报告
						remark:'查看',						//服务评语
					} */
				];
				this.evaluatedList();
			}else if(index == 4){
				this.searchList.show = true;
				this.searchList.noTime = true;
				this.searchList.noUser = true;
				this.searchList.noCity = true;
				this.searchList.noTelphone = true;
				this.searchList.noPosition = true;
				this.tableList.list = [
					{title:'姓名',prop:'name',isClick:false},
					{title:'手机号',prop:'phone',isClick:false},
					{title:'职位名称',prop:'jobTitle',isClick:false},
					{title:'登记时间',prop:'registerTime',isClick:false},
					{title:'工作状态',prop:'jobstatus',isClick:false},
					{title:'自评报告',prop:'report',isClick:true,eventName:'openReport'}
					
				];
				this.tableList.noOperation = true;
				this.tableList.operation = [
					{name:'拉黑',isBtn:true,title:'openDefriend'},
					{name:'提醒',isBtn:true,title:'openFeedback'}
				];
				this.tableList.data = [
					/* {
						name:'寒冰',							//姓名
						phone:'13333333333',				//手机号
						registerTime:'2020-03-29 11:30',	//登记时间
						jobtitle:'月嫂',						//职位名称
						jobstatus:'正在找工作',				//工作状态
						report:'查看',						//自评报告
					} */
				];
				this.evaluatedList();
			}
			
		},
		//	预约人员/待测评人员/再次测评人员 请求数据
		resData(index){
			let params = {
				pageNum: this.cur,
				pageSize: this.pageSize,
				type: index+1
			};
			if(this.userinfo.grade === '10' || this.userinfo.grade === '13'){
				params.branchId = this.userinfo.storesList[0].storesID;
			}else if(this.userinfo.grade === '11'){
				params.branchId = JSON.parse(localStorage.getItem('userinfo')).curBranchId;
			}else{
				params.branchId = this.userinfo.branchId;
			}
			console.log(params);
			this.$houseAxios.post('/housekeeping/OfflineAppraisal/selectAppraisalList',params).then(res => {
				console.log(res);
				if(res.data.code === 1000){
					let result = res.data.data;
					this.totalNum = result.totalNum;
					this.cur = result.pageNum;
					this.tableList.data.splice(0);
					if(result.branchAppointmentVos.length>0){
						result.branchAppointmentVos.forEach(item => {
							item.report = '查看';
							this.tableList.data.push(item);
						})
					}
					
				}
			})
		},
		//查询已测评人员列表或未测评人员列表
		evaluatedList(data){
			console.log(data);
			this.searchData = data;
			let params = {
				pageSize: this.pageSize,
				pageNum: this.cur
			};
			console.log(this.userinfo);
			if(this.userinfo.grade === '10' || this.userinfo.grade === '13'){
				params.branchId = this.userinfo.storesList[0].storesID;
			}else if(this.userinfo.grade === '11'){
				params.branchId = JSON.parse(localStorage.getItem('userinfo')).curBranchId;
			}else{
				params.branchId = this.userinfo.branchId;
			}
			params  = Object.assign(params,data);
			console.log(params);
			if(this.navList.index === 3){			//查询已测评人员列表
				this.$houseAxios.post('/housekeeping/OfflineAppraisal/selectOverAppraisal',params).then(res => {
					console.log(res);
					if(res.data.code === 1000){
						let result = res.data.data;
						this.totalNum = result.totalNum;
						this.tableList.data.splice(0);
						result.finishOrNotAppraisalResponses.forEach(item => {
							if(item.jobstatus === '1'){
								item.jobstatus = '正在找工作';
							}else if(item.jobstatus === '2'){
								item.jobstatus = '在职，正考虑换个新环境';
							}else if(item.jobstatus === '3'){
								item.jobstatus = '在职，暂无跳槽打算';
							}else if(item.jobstatus === '4'){
								item.jobstatus = '在职， 有更好的计会也可以考虑';
							};
							item.username = item.name;
							item.evalreport = '查看';
							item.remark = '查看';
							this.tableList.data.push(item);
						})
					}
				})
			}else if(this.navList.index === 4){		//查询未测评人员列表
				this.$houseAxios.post('/housekeeping/OfflineAppraisal/selectNoAppraisal',params).then(res => { 
					console.log(res);
					if(res.data.code === 1000){
						let result = res.data.data;
						this.totalNum = result.totalNum;
						this.cur = result.pageNum;
						this.tableList.data.splice(0);
						result.finishOrNotAppraisalResponses.forEach(item => {
							jobsJson.jobNameList.forEach(index => {
								if(item.jobTitle == index.key){
									item.jobTitle = index.value;
								}
							})
							jobsJson.jobStatusList.forEach(index => {
								if(item.jobstatus == index.key){
									item.jobstatus = index.value;
								}
							})
							this.tableList.data.push(item);
						})
					}
				})
			}
			
		},
		// 打开--预约人员--回馈弹窗
		openFeedDialog(index){
			console.log(index);
			if(this.navList.index == 3 || this.navList.index == 4){
				this.feedback.title = '提醒';
				this.feedback.noNav = false;
			}else{
				this.feedback.title = '回馈';
				this.feedback.noNav = true;
			}
			this.eventName = 'subFeedback';
			this.feedback.userinfo = index;
			this.$refs.feedback.open();
		},
		// 提交--预约人员--回馈弹窗数据并关闭
		submitFeedback(data){
			console.log(data);
			let userinfo = this.feedback.userinfo;
			console.log(this.userinfo);
			// 请求接口,提交数据
			if(this.feedback.title == '回馈'){
				let params = {
					branchAppointmentId: this.feedback.userinfo.branchAppointmentId,
					operationName: this.userinfo.name,
					operationExplain: data.textarea
				}
				if(data.navName == '预约成功'){
					params.status = 1;
				}else{
					params.status = 2;
				}
				if(this.userinfo.grade === '10' || this.userinfo.grade === '13'){
					params.operationUserId = this.userinfo.account;
				}else if(this.userinfo.grade === '11'){
					params.operationUserId = this.userinfo.account;
				}else{
					params.operationUserId = this.userinfo.account;
				}
				console.log(params);
				this.$houseAxios.post('/housekeeping/OfflineAppraisal/appointFeedback',params).then(res => {
					console.log(res);
					if(res.data.code === 1000){
						this.$message({
							message: '回馈成功',
							type: 'success'
						})
						this.tabSwitch(this.navList.index);
					}else{
						this.$message({
							message: res.data.code,
							type: 'warning'
						})
					}
				})
			}else{
				let params = {
					userid: userinfo.userId,
					remindcontent:data.textarea,
					remark1: 0
				}
				this.$houseAxios.post('/housekeeping/message/remind',params).then(res => {
					console.log(res);
					if(res.data.message === 'success.'){
						this.$message({
							message: '提醒成功',
							type: 'success'
						})
					}else{
						this.$message({
							message: res.data.message,
							type: 'warning'
						})
					}
				})
			}
			this.$refs.feedback.close();
			
		},
		// 打开--待测评人员--测评弹窗
		openEvalDialog(index){
			console.log(index);
			this.evalution.userinfo = index;
			this.$refs.eval.open();
		},
		// 提交--待测评人员--测试的数据
		submitEval(form){
			//请求接口,提交数据
			console.log(form);
			let params = {
				branchAppointmentId: this.evalution.userinfo.branchAppointmentId,
				appraisalType: form.radio,
				phone: this.evalution.userinfo.phone,
				operationName: this.evalution.userinfo.userName,
				branchId:this.evalution.userinfo.branchId,
				operationName: this.userinfo.name,
				operationUserId: this.userinfo.account,
				softs: form.skillList,
				testType: 1,
				starLevel: form.rate,
				certificatePhotos: form.certificatePhotos,
				workPhotos: form.workPhotos,
				referPayLow: form.referPayLow,
				referPayHign: form.referPayHign
			};
			console.log(params);
			this.$houseAxios.post('/housekeeping/OfflineAppraisal/insertBranchAppraisal',params).then(res => {
				console.log(res);
				if(res.data.code === 1000){
					this.$message({
						message:'测评成功',
						type:'success'
					})
					this.intentionJob = '';
					this.tabSwitch(this.navList.index);
				}else{
					this.$message({
						message:res.data.message,
						type:'warning'
					})
				}
			})
			
			//关闭窗口
			this.$refs.eval.close();
		},
		// 打开--已测评人员--拉黑弹窗
		openDefriendDialog(row){
			console.log(row);
			this.unrep.userinfo = row;
			if(row.deleted === '0'){
				this.unrep.title = '拉黑';
				this.unrep.eventName = 'subDefriend';
				this.unrep.linefeedPre = '您确认拉黑此用户吗？';
				this.unrep.linefeedNext = '';
				this.unrep.subCon = '确认拉黑';
			}else{
				this.unrep.title = '取消拉黑';
				this.unrep.eventName = 'subDefriend';
				this.unrep.linefeedPre = '您确认取消拉黑此用户吗？';
				this.unrep.linefeedNext = '';
				this.unrep.subCon = '确认取消拉黑';
			}
			this.$refs.unrep.open();
		},
		// 确认--已测评人员--拉黑弹窗
		submitDefriend(){
			let params = {
				userId:this.unrep.userinfo.userId
			}
			if(this.unrep.userinfo.deleted === '0'){
				params.deleted = '1';
			}else{
				params.deleted = '0';
			}
			this.$houseAxios.post('/housekeeping/Employer/deleteEmployer',params).then(res => {
				console.log(res);
				if(res.data.code === 1000){
					if(this.unrep.userinfo.deleted === '0'){
						this.$message({
							message:'拉黑成功',
							type:'success'
						})
					}else{
						this.$message({
							message:'取消拉黑成功',
							type:'success'
						})
					}
				}else{
					this.$message({
						message:res.data.message,
						type:'warning'
					})
				}
				this.$refs.unrep.close();
				this.tabSwitch(this.navList.index);
			})
		},
		// 打开--待测评人员--未报到弹窗
		openUnrepDialog(row){
			console.log(row);
			this.unrep.title = '未报到';
			this.unrep.linefeedPre = '确认该家政人员';
			this.unrep.linefeedNext = '是否未按时参加线下辅导站测评';
			this.unrep.subCon = '确认未报到';
			this.unrep.eventName = 'subUnrep';
			this.unrep.userinfo = row;
			this.$refs.unrep.open();
		},
		// 确认--待测评人员-未过来报道
		submitEnrep(){
			//请求数据,提交接口
			let userMsg = this.unrep.userinfo;
			let params = {
				branchAppointmentId: userMsg.branchAppointmentId,
				operationName: this.userinfo.name,
				operationUserId: this.userinfo.account,
				branchId: userMsg.branchId
			}
			this.$houseAxios.post('/housekeeping/OfflineAppraisal/noReport',params).then(res => {
				console.log(res);
				if(res.data.code === 1000){
					this.$message({
						message: '操作成功',
						type: 'success'
					})
					this.tabSwitch(this.navList.index);
				}
			})
			this.$refs.unrep.close();
		},
		// 打开--已测评人员--姓名并能进行修改信息模板
		openViewchangeDialog(index){
			console.log(index);
			this.viewchanges.userinfo = index;
			this.getEvaluationData(index,'viewchanges');
			this.$refs.viewchanges.open()
		},
		// 确认--已测评人员--姓名修改并保存提交操作
		modifyInfo(){
			//请求接口,提交修改的数据
			console.log(this.userinfo);
			console.log(this.viewchanges);
			let userMsg = this.viewchanges.userinfo;
			let params = {
				branchAppraisalId: userMsg.branchAppraisalId,
				branchAppointmentId: userMsg.branchAppointmentId,
				phone: userMsg.phone,
				branchId: userMsg.branchId,
				operationName: this.userinfo.name,
				operationUserId: this.userinfo.account,
				testType: 1,
				softs: [],
				workPhotos: this.viewchanges.workPhotos,
				certificatePhotos: this.viewchanges.certificatePhotos,
				starLevel: this.viewchanges.rate
			};
			jobsJson.jobNameList.forEach(item => {
				if(item.value == this.viewchanges.job){
					params.appraisalType = item.key;
				}
			})
			jobsJson.moneyList.forEach(item => {
				if(item.value == this.viewchanges.value && item.value != 1){
					let money = item.label.split('-');
					params.referPayLow = money[0];
					params.referPayHign = money[1];
				}else if(item.value == this.viewchanges.value && item.value == 1){
					params.referPayLow = 0;
					params.referPayHign = 1000;
				}
			})
			this.viewchanges.skillList.forEach(item => {
				delete item.items;
				params.softs.push(item); 
			})
			console.log(params);
			this.$houseAxios.post('/housekeeping/OfflineAppraisal/updateBranchAppraisal',params).then(res => {
				console.log(res);
				if(res.data.code === 1000){
					this.$message({
						message: '信息修改成功！',
						type: 'success'
					})
				}else{
					this.$message({
						message: res.data.message,
						type: 'warning'
					})
				}
			})
			this.$refs.viewchanges.close();
		},
		// 打开--已测评人员--测评报告弹窗
		openAssessDialog(index){
			console.log(index);
			this.getEvaluationData(index,'assess');
			this.$refs.assess.open();
		},
		//获取测评报告数据
		getEvaluationData(index,dataTitle){
			this.$houseAxios.post('/housekeeping/OfflineAppraisal/selectAppraisalRigidSoftPC',{branchAppointmentId:index.branchAppointmentId}).then(res => {
				console.log(res);
				if(res.data.code === 1000){
					let result = res.data.data;
					this[dataTitle].username = index.name;
					this[dataTitle].tel = index.phone;
					this[dataTitle].rate = result.starLevel;
					this[dataTitle].workPhotos = result.workPhotos;
					this[dataTitle].certificatePhotos = result.certificatePhotos;
					jobsJson.jobNameList.forEach(item => {
						if(item.key == result.appraisalType){
							this[dataTitle].job = item.value;
						}
					});
					result.softs.forEach(item => {
						item.items = [
							{name:'一般',label:'1',id:1},
							{name:'良好',label:'2',id:2},
							{name:'优秀',label:'3',id:3}
						]
					})
					let money = result.referPayLow + '-' + result.referPayHign;
					jobsJson.moneyList.forEach(item => {
						if(item.label == money){
							this[dataTitle].value = item.value;
						}
					})
					this[dataTitle].skillList = result.softs;
					if(dataTitle == "viewchanges"){
						result.operationRecordVos.forEach(item => {
							if(item.operationType == '3'){
								item.operationType = '首次测评';
							}else{
								item.operationType = '修改';
							}
						})
						this.viewchanges.dataList.data = result.operationRecordVos;
					}
				}
			})
		},
		// 打开--已测评人员--服务评语弹窗
		openRemarkDialog(index){
			console.log(index);
			let params = {
				employeeId: index.userId,
				pageNum: this.remark.cur,
				pageSize: this.remark.pageSize
			}
			this.$houseAxios.post('/housekeeping/OfflineAppraisal/selecteValuatePC',params).then(res => {
				console.log(res);
				if(res.data.code === 1000){
					let result = res.data.data;
					this.remark.data.splice(0);
					this.remark.totalNum = result.totalNum;
					result.valuatePCResponses.forEach(item => {
						item.salaryRange = item.payFloor + '-' + item.payUpper;
						if(item.jobStatus == '1'){
							item.jobStatus = '期后离职';
						}else if(item.jobStatus == '2'){
							item.jobStatus = '期后在职';
						}
						jobsJson.jobNameList.forEach(item1 => {
							if(item1.key == item.jobTitle){
								item.jobTitle = item1.value;
							}
						})
						this.remark.data.push(item);
					})
				}
			})
			this.$refs.remark.open();
		},
		//当前页是第几页,点击的第几页的时候调用这个函数
		pageChange(p) {
			// 点击的时候传过来一个参数，这个参数就是所点击的当前页数，
			// 然后把这个当前页数转换成字符串形式赋值给page，
			// 然后把page这个参数传给search这个方法
			console.log(p);
			this.cur = p;
			if(this.navList.index < 3){
				this.resData(this.navList.index);
			}else{
				this.evaluatedList(this.searchData);
			}
		},
		//每页有多少条,10,20,50等,点击选择的时候调用这个方法
		handleSizeChange (val) {
			console.log(val);
			this.pageSize = val;
			if(this.navList.index < 3){
				this.resData(this.navList.index);
			}else{
				this.evaluatedList(this.searchData);
			}
		},
		//清空数据
		reset(){
			this.cur = 1;
			this.pageSize = 10;
			this.searchList = {};
			this.tableList = {};
		}
	}
}
</script>

<style scoped="scoped">
.container{
	background-color: #fff;
	height: 100%;
	padding-left: 20px;
}
.header-title{
	padding: 0 0 20px 0;
	border-bottom: 1px solid #D2D2D2;
}
.header-title span{
	width: 15px;
	height: 30px;
	background-color: #0064E4;
	margin-right: 20px;
	float: left;
}
.header-title p{
	float: left;
	font-weight: bold;
	line-height: 30px;
}
.pageBox{
	margin-top: 20px;
}
</style>
